package com.example.sunsg.okhttptest.activity;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;

import com.breadtrip.R;

public class TouchActivity extends AppCompatActivity {

    public static void launch(Activity activity){
        Intent intent = new Intent(activity,TouchActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_touch);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {

        switch (ev.getAction()){
            case MotionEvent.ACTION_DOWN:
                Log.i("test","\nactivity dispatchTouchEvent down\n");
                break;
            case MotionEvent.ACTION_MOVE:
//                Log.i("test","\nactivity dispatchTouchEvent ACTION_MOVE\n");
                break;
            case MotionEvent.ACTION_UP:
                Log.i("test","\nactivity dispatchTouchEvent ACTION_UP\n");
                break;
        }
        return super.dispatchTouchEvent(ev);//return super 事件才往下传 reurn true 或者 false 都不往下传
//        return false;

    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        switch (event.getAction()){
            case MotionEvent.ACTION_DOWN:
                Log.i("test","\nactivity onTouchEvent down\n");
                break;
            case MotionEvent.ACTION_MOVE:
//                Log.i("test","\nactivity onTouchEvent ACTION_MOVE\n");
                break;
            case MotionEvent.ACTION_UP:
                Log.i("test","\nactivity onTouchEvent ACTION_UP\n");
                break;
        }
        return super.onTouchEvent(event);
    }
}
